package com.xs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.cloud.context.config.annotation.RefreshScope;

@RestController
@RequestMapping("/zookeeper")
@RefreshScope // 必须添加，否则不会自动刷新name的值
public class ZkController {
	@Autowired
	private Environment environment;

	@Value("${level}")
	private String level;

	@GetMapping("/getLevel")
	public String hello() {
		return "level  is  " + level;
	}

	@GetMapping("/env")
	public String test() {
		String name = environment.getProperty("level");
		return "leval is " + name;

	}
}
